package com.jjyu.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class Result<T> {
    /**
     * 状态码 200表示成功，500表示失败
     */
    private Integer code;
    /**
     * 提示信息
     */
    private String message;
    /**
     * 返回数据
     */
    private T data;

    public static <E> Result<E> success(E data) {
        return new Result<>(200, "success", data);
    }

    public static <E> Result<E> error(String message, E data) {
        return new Result<>(500, message, data);
    }

    public static Result success() {
        return new Result(200, "success", null);
    }

    public static Result error(String message) {
        return new Result(500, message, null);
    }

}
